package face.pay.common.income.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import face.pay.common.income.IIncomeBaseService;
import face.pay.dao.IncomeInfoDao;
import face.pay.entity.IncomeInfo;
import face.pay.entity.UserInfo;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Auther: zkj
 * @Date: 2019/7/23 10:40
 * @Description:
 */
@Service
public class IncomeBaseServiceImpl implements IIncomeBaseService {


    @Autowired
    IncomeInfoDao incomeInfoDao;


    public PageData queryData(IncomeInfo incomeInfo, PageParam pageParam, UserInfo loginUser){

        PageHelper.startPage(pageParam.getPageNo(),pageParam.getPageSize());

        List<IncomeInfo> incomeInfos = this.incomeInfoDao.queryList(incomeInfo);

        PageInfo<IncomeInfo> pageInfo = new PageInfo <IncomeInfo>(incomeInfos);

        PageData<IncomeInfo> pageData = new PageData<IncomeInfo>(pageInfo.getTotal(),incomeInfos);

        return pageData;

    }
}
